package com.app.mvc.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.app.mvc.dao.CategoryDao;
import com.app.mvc.dao.DealDao;
import com.app.mvc.dao.LocationDao;
import com.app.mvc.dao.impl.CategoryDaoImpl;
import com.app.mvc.dao.impl.DealDaoImpl;
import com.app.mvc.dao.impl.LocationDaoImpl;
import com.app.mvc.model.Category;
import com.app.mvc.model.Deal;
import com.app.mvc.model.Location;

public class LeftCategoryController extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		LocationDao ce = new LocationDaoImpl();
		CategoryDao de = new CategoryDaoImpl();

		List<Location> result = ce.getAll();

		List<Category> categories = new ArrayList<Category>();
		for (Location location : result) {
			categories = de.getCategoryByLocation(location.getId());
		}
		request.setAttribute("categories", categories);
		request.setAttribute("styles", result);
		RequestDispatcher view = request.getRequestDispatcher("jsp/index.jsp");
		view.forward(request, response);
	}
}
